package com.wanggsx.library.base.view;

/**
 * ```
 * author: wanggsx
 * blog  : http://blog.csdn.net/wanggsx918
 * time  : 2018/03/23
 * desc  : base about lazy fragment
 * ```
 */
public abstract class BaseLazyFragment extends BaseFragment {

    private static final String TAG = "BaseLazyFragment";

    private boolean isDataLoaded = false;

    abstract void doLazyBusiness();

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser && !isDataLoaded){
            doLazyBusiness();
            isDataLoaded = true;
        }
    }

    public void doBusiness() {
        if (super.getUserVisibleHint()) {
            doLazyBusiness();
            isDataLoaded = true;
        }
    }
}
